<template>
  <div class="box">
    <div class="header"></div>
    <div class="content">
      <van-image :src="loginLogo" class="image"></van-image>
    </div>
    <div class="footer">
      <div class="login-box user">
        <input type="text" placeholder="账号" class="input" v-model="login.username" />
      </div>
      <div class="login-box password">
        <input type="text" placeholder="密码" class="input" v-model="login.password" />
      </div>
      <div class="login-button">
        <van-button type="primary" block class="btn" @click="logIn">登录</van-button>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import loginLogo from '@/assets/login/login-logo.svg'
import { useRouter } from 'vue-router'
const router = useRouter()

const login = reactive({
  username: '',
  password: ''
})
const logIn = () => {
  if (login.username.trim() == '') {
    return showToast('请输入账号')
  }
  if (login.password.trim() == '') {
    return showToast('请输入密码')
  }
  // 跳转首页
  router.push('/home')
}
</script>
<style scoped>
.header {
  width: 100%;
  height: 214px;
  margin: 0 auto;
  background: url('@/assets/login/login-bg.svg') no-repeat;
}
.content {
  text-align: center;
  padding: 12px 0 16px;
  .image {
    width: 173px;
    height: 54px;
  }
}
.footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  .login-box {
    position: relative;
    &::before {
      display: block;
      content: '';
      position: absolute;
      width: 20px;
      height: 20px;
      top: 50%;
      transform: translate(0, -50%);
      left: 23.5px;
      z-index: 100;
    }
    &.user {
      &::before {
        background: url('@/assets/login/login-person.svg') center center no-repeat;
        background-size: cover;
      }
    }
    &.password {
      margin-top: 12px;
      &::before {
        background: url('@/assets/login/login-lock.svg') center center no-repeat;
        background-size: cover;
      }
    }
    input {
      appearance: none;
      -moz-appearance: none;
      -webkit-appearance: none;
      font-size: 14px;
      width: 288px;
      height: 48px;
      flex-shrink: 0;
      border-radius: 22px;
      border: 1px solid #bad3fd;
      background: #f5f9ff;
      border: none;
      padding: 0 20px 0 49px;
      box-sizing: border-box;
    }
  }
  .login-button {
    padding-top: 45px;
    .btn {
      width: 169.41px;
      height: 48px;
      border-radius: 26.5px;
      background: linear-gradient(90deg, #61b9fe 0%, #3e77ff 100%);
      box-shadow: 0 2px 4px 0 #00000026;
      font-size: 16px;
      letter-spacing: 0.02px;
      color: #fff;
    }
  }
}
</style>
